<template>
	<view class="main">
		
		<view class="title">
			<alltitleVue :title="title" />
		</view>


		<view class="bg">
			<image :src="photoUrl || bg" mode=""></image>
		</view>

		<view class="btn" @click="answer">
			开始测试
		</view>
		<view class="btn-bot" @click="answerList"  v-if="sort.length>0">
			做一次体质测试，及时调整养生计划
		</view>


	</view>
</template>

<script>
	import {
		getquestionnaireAnswer,
	
	} from '../../service/api.js'
	import config from "../../utils/config";
	import loginVue from "../../components/login.vue";
	
	import {
		toast,
		getStore,
		setStore,
		removeStore
	} from "@/utils/index";
	export default {
		components: {
			
			
		},
		data() {
			return {
				photoUrl:"",
				bg: config.ossHost + '2024/12/29/d4dce530e9c045378154435d7ae07f81.png',
				
				title: "中医体质辨识",
				id:0,
				sort:[]

			}
		},
		computed: {
			
			
		},
		onLoad(options) {
			
			if(options.id){
				this.id=options.id
				this.title=options.name
				this.photoUrl=options.photoUrl;
				console.log(this.photoUrl);
			}
			this.getquestion();
		},
		
		methods: {
			answerList(){
				uni.navigateTo({
					url: `/outpatient/answerList/index`
				});
			},
			async getquestion() {
				let res = await getquestionnaireAnswer();
				if (res.code==200) {
					this.sort=res.rows
				}
			},
			answer() {
				if (this.token != "") {
					console.log(this.photoUrl,'22222')
					uni.navigateTo({
						url: '/outpatient/answer/index?id='+this.id+"&photoUrl=" + this.photoUrl
					});
				} else {
					if (this.isModalVisible) {
						this.isModalVisible = true;
					} else {
						this.isModalVisible = true;
					}
				}
			},
			isModal(item) {
				this.isModalVisible = item
			},
		}

	}
</script>

<style lang="scss" scoped>
	.main {
		width: 100%;
		height: 100vh;
		padding: 0;
		margin: 0;
		background: #F5F3F0;
	}

	.title {
		background: #FFFFFF;
	}

	.bg {
		width: 100%;
		height: calc(100vh - 415rpx);
		padding: 24rpx;

		image {
			width: 702rpx;
			height: 100%;
		}
	}

	.btn {
		width: calc(100vw - 48rpx);
		height: 82rpx;
		background: #CCA566;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		text-align: center;
		line-height: 82rpx;
		font-weight: 400;
		font-size: 32rpx;
		color: #FFFFFF;
		margin: 0 24rpx;
	}

	.btn-bot {
		text-align: center;
		margin-top: 20rpx;
		font-size: 20rpx;
		color: #805D33;
	}
</style>